'use strict'

const Controller = require('egg').Controller

class RbacController extends Controller {
  async auth() {
    const { ctx, app } = this
    const userInfo = ctx.state.userInfo
    if (userInfo.id === 1) {
      ctx.body = [
        {
          path: '/layout/home',
          text: '首页',
          icon: 'el-icon-message',
        },
        {
          path: '/layout/register',
          text: '注册',
          icon: '',
        },
        {
          path: '/layout/blogs',
          text: '博客管理',
          icon: '',
        },
        {
          path: '/layout/users',
          text: '用户管理',
          icon: '',
        },
        {
          path: '/layout/echarts',
          text: '图标管理',
          icon: '',
        },
        {
          path: '/layout/code',
          text: '验证码管理',
          icon: '',
        },
      ]
    } else {
      ctx.body = [
        {
          path: '/layout/home',
          text: '首页',
          icon: 'el-icon-message',
        },
        {
          path: '/layout/register',
          text: '注册',
          icon: '',
        },
        {
          path: '/layout/blogs',
          text: '博客管理',
          icon: '',
        },
      ]
    }
  }
}

module.exports = RbacController
